// import { Sequelize } from "sequelize";
//
//
// const sequelize = new Sequelize('todo', 'ysp123', 'ysp123', {
//     host: '175.24.81.97',
//     dialect: "mysql",
//     timezone: '+08:00',
//     pool: {                 // 使用连接池
//         max: 5,
//         min: 0,
//         acquire: 30000,
//         idle: 10000,
//     },
// });


// const { Sequelize } = require('sequelize');
const Sequelize = require('sequelize')
// import { Sequelize } from "sequelize";

const sequelize = new Sequelize('todo', 'ysp123', 'ysp123', {
    host: '175.24.81.97',
    dialect: "mysql",
    dialectOptions: {
        charset: 'utf8mb4',
        supportBigNumbers: true,
        bigNumberStrings: true
    },
    pool: {
        max: 5,
        min: 0,
        acquire: 30000,
        idle: 10000,
    },
    timezone: '+08:00'
})

// exports.sequelize = sequelize;
module.exports = sequelize;

// module.export = {
//     sequelize,
//     Sequelize
// }

    // (async ()=>{
    //     try {
    //         await sequelize.authenticate();
    //         console.log("Connection has been established successfully.");
    //     }catch(error){
    //         console.error("Unable to connect to the database:", error);
    //     }
    // })()
// sequelize.authenticate().then(() => {
//     console.log('连接数据库成功！')
// }).catch(err => {
//     console.log(err)
//     console.log('连接数据库失败！')
// })


// 测试连接
// (async function () {
//   try {
//     await sequelize.authenticate();
//     console.log("Connection has been established successfully.");
//   } catch (error) {
//     console.error("Unable to connect to the database:", error);
//   }
// })();

// export default sequelize;
